
#include "GraphicsWindow.h"



#if defined(WIN_WIN)

GraphicsWindow::GraphicsWindow()
{
}

/*----------------------------------------------------------------------------*/
GraphicsWindow::~GraphicsWindow()
{
}

/*----------------------------------------------------------------------------*/
void GraphicsWindow::createWindow(string winName, int w, int h, int x, int y, bool fullscreen)
{
	gws.initWindow(this);
	gws.winCreateWindow(winName, w, h, x, y, fullscreen);
}

/*----------------------------------------------------------------------------*/
void GraphicsWindow::startWindow()
{
	gws.winMainLoop();
}

/*----------------------------------------------------------------------------*/
void GraphicsWindow::postRedisplay()
{
	gws.winPostRedisplay();
}

/*----------------------------------------------------------------------------*/
void GraphicsWindow::swapBuffers()
{
	gws.winSwapBuffers();
}

/*----------------------------------------------------------------------------*/
void GraphicsWindow::killWindow()
{
	gws.winExitMainLoop();
}




#elif defined(GLUT_WIN)

GraphicsWindow::GraphicsWindow()
{
}

/*----------------------------------------------------------------------------*/
GraphicsWindow::~GraphicsWindow()
{
}

/*----------------------------------------------------------------------------*/
void GraphicsWindow::createWindow(string winName, int w, int h, int x, int y, bool fullscreen)
{
	windowGood = false;

	char * dummy_argv[1];
    dummy_argv[0] = "FOO";
    int dummy_argc = 1;

	// Standard GLUT initialization 
	glutInit(&dummy_argc, dummy_argv);

	// double buffer, RGB color mode 
	glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
  
	glutInitWindowSize (w, h); // set win size
	glutInitWindowPosition (x, y); // place win
	// set window title 
	glutCreateWindow (winName.c_str());


	gws.initWindow(this);

	windowGood = true;
}

/*----------------------------------------------------------------------------*/
void GraphicsWindow::startWindow()
{
	if(windowGood)
	   glutMainLoop();
}

/*----------------------------------------------------------------------------*/
void GraphicsWindow::killWindow()
{
}

/*----------------------------------------------------------------------------*/
void GraphicsWindow::postRedisplay()
{
	glutPostRedisplay();
}

/*----------------------------------------------------------------------------*/
void GraphicsWindow::swapBuffers()
{
	glutSwapBuffers();
}

#endif